package com.doradance.app.appactivity.message;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.doradance.R;
import com.pachong.android.baseuicomponent.activity.BaseActivity;

import org.json.JSONException;
import org.json.JSONObject;

import butterknife.Bind;

public class MessageContentActivity extends BaseActivity {
    @Bind(R.id.tv_message_title)
    TextView mTvMessageTitle;
    @Bind(R.id.tv_message_content)
    TextView mTvMessageContent;
    private String content;
    String content1;
    String title;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initData();
        content = getIntent().getStringExtra("content");
        try {
            JSONObject jsonObject = new JSONObject(content);
            content1 = jsonObject.getString("content");
            title = jsonObject.getString("title");
            mTvMessageTitle.setText(title);
            mTvMessageContent.setText(content1);
        } catch (JSONException e) {
            e.printStackTrace();
        }


    }

    private void initData() {
        setTitle("消息详情");
        getCustomToolbar().addLeftImageButton(R.mipmap.back, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    public View createDataView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.activity_message_content, null);
    }

    public static void start(Activity activity, String content) {
        Intent intent = new Intent(activity, MessageContentActivity.class);
        intent.putExtra("content", content);
        activity.startActivity(intent);
    }
}
